package binary_tree.Heap;

import stack_and_queue.queue.Queue;

/**
 * @Description: 基于最大堆的优先级队列
 * @Author Stark
 * @Date 2022/3/6 9:35
 **/
public class PriorityQueue implements Queue<Integer> {
    private MaxHeap heap;
    public PriorityQueue(){
        heap = new MaxHeap(10);
    }
    @Override
    public void offer(Integer val) {
        heap.add(val);
    }

    @Override
    public Integer poll() {
        return heap.extractMax();
    }

    @Override
    public Integer peek() {
        return heap.peekMax();
    }

    @Override
    public boolean isEmpty() {
        return heap.isEmpty();
    }

    @Override
    public String toString() {
        return heap.toString();
    }
}
